﻿#include "logindlg.h"
#include "ui_logindlg.h"
#include <QMessageBox>
LoginDLg::LoginDLg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LoginDLg)
{
    ui->setupUi(this);
    this->move(1040,45);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    setWindowFlags(Qt::FramelessWindowHint|Qt::WindowMinimizeButtonHint);

    m_dConsumer = new ConsumerDlg(this);

    m_dConsumer->hide();
    ui->manageBt->hide();
}

LoginDLg::~LoginDLg()
{
    delete ui;
}

void LoginDLg::on_lockBt_clicked()
{
    // 验证密码
    QString sUser = ui->lineEdit_1->text();
//    QString sPassWord = ui->lineEdit_2->text();
    QString sPassWord = "123456";
    if(sUser != "admin"){
        QMessageBox::information(this,"Error", QString::fromLocal8Bit("用户名错误!"));
         ui->lineEdit_1->setText("admin");
        return;
    }
    if(sPassWord != "123456"){
        QMessageBox::information(this,"Error", QString::fromLocal8Bit("密码错误!"));
        ui->lineEdit_2->setText("");
        return;
    }

    emit sigLogDlgInfo(1);
    QMessageBox::information(this,"Suceess", QString::fromLocal8Bit("登录成功!"));
}

void LoginDLg::on_loginBt_clicked()
{
    emit sigLogDlgInfo(2);
    QMessageBox::information(this,"Suceess", QString::fromLocal8Bit("锁定成功!"));
}

void LoginDLg::on_manageBt_clicked()
{
    m_dConsumer->show();
}
